package com.itheima.health.controller;

import com.itheima.health.common.MessageConst;
import com.itheima.health.entity.PageResult;
import com.itheima.health.entity.QueryPageBean;
import com.itheima.health.entity.Result;
import com.itheima.health.pojo.TSaveItemgroup;
import com.itheima.health.service.TSaveItemgroupService;
import io.lettuce.core.dynamic.annotation.Param;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

/**
 * (TSaveItemgroup)表控制层
 *
 * @author makejava
 * @since 2021-04-21 11:21:41
 */
@RestController
@RequestMapping("tSaveItemgroup")
@Slf4j
public class TSaveItemgroupController {
    /**
     * 服务对象
     */
    @DubboReference
    private TSaveItemgroupService tSaveItemgroupService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("findById/{id}")
    public TSaveItemgroup selectOne(@PathVariable Integer id) {
        return tSaveItemgroupService.queryById(id);
    }

    @PostMapping("edit")
    public Result edit(@RequestBody TSaveItemgroup tSaveItemgroup){
        tSaveItemgroupService.update(tSaveItemgroup);
        return new Result(true, MessageConst.ACTION_SUCCESS);
    }

    @GetMapping("delete")
    public Result delete(@Param("id") Integer id){
        tSaveItemgroupService.deleteById(id);
        return new Result(true,MessageConst.ACTION_SUCCESS);
    }

    @GetMapping("findpage")
    public Result findpage(QueryPageBean queryPageBean){
        PageResult page=tSaveItemgroupService.findpage(queryPageBean);
        return new Result(true,MessageConst.ACTION_SUCCESS,page);
    }

}
